﻿using System;
using CriWare.CriTimeline.Mana;
using IQIGame.Onigao.Game;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

namespace IQIGame.Onigao.GamePlay
{
    public class CriwareVideoClip : CriManaClip
    {
        [SerializeField] public string videoPath;
        [SerializeField] public AnimationCurve alpha;

        public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
        {
            var rEntityDriver = owner.GetComponent<EntityDriver>();
            var rUnitView = BattleClientUtil.GetUnitViewByEntityDriver(rEntityDriver);
            var rVideoPath = string.Empty;
            if (rUnitView != null)
            {
                rVideoPath = FrameworkPath.GetVideoFilePath(PathConstant.GetUnitVideoPath(rUnitView.roleName, this.videoPath));
            }
            this.m_moviePath = rVideoPath;
            var rPlayable = ScriptPlayable<CriwareVideoBehaviour>.Create(graph);
            return rPlayable;
        }
    }
}